package com.fqgj.xjd.user.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserContactEmergencyDao;
import com.fqgj.xjd.user.entity.UserContactEmergencyEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: zhangxingyun
* Date: 2017-07-20
* Time: 18:38:53.082
*/

@Repository
public class UserContactEmergencyDaoImpl extends AbstractBaseMapper<UserContactEmergencyEntity> implements UserContactEmergencyDao {
    @Override
    public UserContactEmergencyEntity selectByUserCode(String userCode) {
        return getSqlSession().selectOne(getStatement("selectByUserCode"), userCode);
    }

    @Override
    public int updateByUserCode(String userCode, UserContactEmergencyEntity entity) {
        entity.setGmtModified(new Date());
        entity.setUserCode(userCode);
        return getSqlSession().update(getStatement("updateByUserCode"), entity);
    }

    @Override
    public List<UserContactEmergencyEntity> selectByFamilyMobile(String userCode, String mobile) {
        Map<String, Object> map = new HashMap<>();
        map.put("familyMobile", mobile);
        map.put("userCode", userCode);
        return getSqlSession().selectList(getStatement("selectByFamilyMobile"), map);
    }

    @Override
    public List<UserContactEmergencyEntity> selectByFriendMobile(String userCode, String mobile) {
        Map<String, Object> map = new HashMap<>();
        map.put("friendMobile", mobile);
        map.put("userCode", userCode);
        return getSqlSession().selectList(getStatement("selectByFriendMobile"), map);
    }
}